<?php

use Biz\model\activity\Kohler;
use Biz\service\brand\Brand;
use Doraemon\model\Topic\TopicActivity as mTopicActivity;
use Doraemon\service\Format\Note\HandleNote;
use Doraemon\service\statSign\Basic as statSign;
use Doraemon\tools\BlockType;
use hhz\constant\redis\redisKeys;
use Doraemon\service\Topic\TopicActivity;

class KohlerTopicAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_NOTHING;

    public function main()
    {
        $keyword = $this->getRequest()->getQuery('keyword', '浴室开放麦');
        $page = $this->getRequest()->getQuery('page', 1);
        $pageSize = 20;
        $noteIds = TopicActivity::getNoteIdsByKeyword($keyword, $this->uid, TopicActivity::SORT_TYPE_DEFAULT, $page, $pageSize);
        $isOver = count($noteIds) < $pageSize ? 1 : 0;
        $topicInfo = mTopicActivity::getDetailByTitle($keyword);
        $topicId = $topicInfo['id'] ?? 0;
        $photoIds = [];
        if (isset($noteIds) && $noteIds) {
            if (1 == $page) {
                $photoIds = TopicActivity::insertRecommendAnswer($noteIds, $topicId, TopicActivity::RECOMMEND_ANSWER_IN_ALL);
            } else {
                $photoIds = TopicActivity::filterRecommendAnswer($noteIds, $topicId, TopicActivity::RECOMMEND_ANSWER_IN_ALL);
            }
        }

        $list = $photoIds ? HandleNote::handleNote($photoIds, HandleNote::MASONRY_LAYOUTS, $this->uid) : [];
        $this->setSuccess(['list' => array_values($list), 'is_over' => $isOver]);
    }
}